<?php


namespace app\common\controller;


use app\common\model\Parkcar;
use app\common\model\Parkinfo;
use think\Controller;

class CommonBase extends Controller
{
    public function getparkinfo($parkno)
    {
        $Parkinfo = new Parkinfo();
        $info = $Parkinfo->where(['parkno' => $parkno])->find();
        return $info;
    }
    public function getparkinfobyid($parkid)
    {
        $Parkinfo = new Parkinfo();
        $info = $Parkinfo->where(['id' => $parkid])->find();
        return $info;
    }
    public function upparkcar($carno,$parkid,$parklogid){
        $map['parkid']=$parkid;
        $map['carno']=$carno;
        $Parkcar=new Parkcar();
        $info=$Parkcar->where($map)->find();
        if($info){
            $Parkcar->save(['last_log_id'=>$parklogid],$map);
        }else{
            $Parkcar->save(['last_log_id'=>$parklogid,'carno'=>$carno,'parkid'=>$parkid]);
        }
    }
    public function getcarlastid($parkid,$carno){
        $Parkcar=new Parkcar();
        $last_log_id=$Parkcar->where(['parkid'=>$parkid,'carno'=>$carno])->value('last_log_id');
        return $last_log_id;
    }

}